<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:url('Goods/index')}">商品管理</a></li>
		</ul>
		<php>$user_statuses=array("0"=>"普通会员","1"=>"黄金会员","2"=>"铂金会员","3"=>"区级合伙人","4"=>"市级合伙人","5"=>"省级合伙人");</php>
		<php>$user_account_statuses=array("0"=>"正常","1"=>"已冻结");</php>
		<table class="table table-hover table-bordered">
			<thead>
				<tr>
					<th width="50">ID</th>
					<th>商品名称</th>
					<th>库存数量/台</th>
					<th>单价</th>
					<th>状态</th>
					<th width="140">操作</th>
				</tr>
			</thead>
			<tbody>
				<foreach name="goodsLists" item="vo">
				<tr>
					<td>{$vo.goods_id}</td>
					<td>{$vo.goods_title}</td>
					<td>{$vo.goods_stock}</td>
					<td>
						{$vo.goods_price}元
					</td>
					<td>
						<label class="radio-inline">
							<input type="radio" onclick="changeStatus($(this),'{$vo.goods_id}');" name="goods_status" value="1" <if condition="$vo['goods_status'] eq 1">checked</if> > 出售
						</label>
						<label class="radio-inline">
							<input type="radio" onclick="changeStatus($(this),'{$vo.goods_id}');" name="goods_status" value="2" <if condition="$vo['goods_status'] eq 2">checked</if> > 下架
						</label>
					</td>
					<td>
						<a class="btn btn-xs btn-primary btn-warning " href='{:url("goods/edit",array("id"=>$vo["goods_id"]))}'>编辑</a>
					</td>
				</tr>
				</foreach>
			</tbody>
		</table>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
</body>
<script>
	function changeStatus(obj,goods_id) {
		var goods_status = obj.val();
		console.log(goods_status);
		var text = goods_status == 1 ? "出售" : "下架";
		if(confirm('确定'+text+'该商品？')){
			$.ajax({
				url:"{:url('goods/changeStatus')}",
				data:{goods_id,goods_id,status:goods_status},
				dataType:"json",
				type:"get",
				success:function (data) {
					console.log(data);
					if(data.code == 10000){
						window.location.reload();
					}else{
						alert(data.msg);
						return false;
					}
				}
			});
		}


	}
</script>
</html>